package com.example.takeaway.serivce.impl;

import java.util.List;

import com.example.takeaway.entity.Comments;
import com.example.takeaway.mapper.CommentsMapper;
import com.example.takeaway.serivce.ICommentsService;
import com.example.takeaway.utils.PageResult;
import com.example.takeaway.utils.PageUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * commentService业务层处理
 * 
 * @author ruoyi
 * @date 2025-06-02
 */
@Service
public class CommentsServiceImpl implements ICommentsService
{
    @Autowired
    private CommentsMapper commentsMapper;

    /**
     * 查询comment
     * 
     * @param commentsid comment主键
     * @return comment
     */
    @Override
    public Comments selectCommentsByCommentsid(Long commentsid)
    {
        return commentsMapper.selectCommentsByCommentsid(commentsid);
    }

    /**
     * 查询comment列表
     * 
     * @param comments comment
     * @return comment
     */
    @Override
    public PageResult selectCommentsList(Comments comments, int pageNum, int pageSize)
    {
        PageHelper.startPage(pageNum,pageSize);
        List<Comments> list = commentsMapper.selectCommentsList(comments);
        PageInfo<Comments> pageInfo = new PageInfo<>(list);
        PageResult pageResult = PageUtils.getPageResult(pageInfo);
        return pageResult;
    }

    /**
     * 新增comment
     * 
     * @param comments comment
     * @return 结果
     */
    @Override
    public int insertComments(Comments comments)
    {
        return commentsMapper.insertComments(comments);
    }

    /**
     * 修改comment
     * 
     * @param comments comment
     * @return 结果
     */
    @Override
    public int updateComments(Comments comments)
    {
        return commentsMapper.updateComments(comments);
    }

    /**
     * 批量删除comment
     * 
     * @param commentsids 需要删除的comment主键
     * @return 结果
     */
    @Override
    public int deleteCommentsByCommentsids(Long[] commentsids)
    {
        return commentsMapper.deleteCommentsByCommentsids(commentsids);
    }

    /**
     * 删除comment信息
     * 
     * @param commentsid comment主键
     * @return 结果
     */
    @Override
    public int deleteCommentsByCommentsid(Long commentsid)
    {
        return commentsMapper.deleteCommentsByCommentsid(commentsid);
    }
}
